\input{prefix}

% =============================================================================
% =============================================================================
\begin{document}


% =============================================================================
% model of quantization process
\begin{tikzpicture}[auto, node distance=2cm]
    \node [input, name=input] {};
    \node [sum,right of=input, xshift=1cm] (sum){$+$};
    \node [input, below of=sum,yshift=1cm] (error) {};
    \node [output, right of=sum,xshift=0cm] (output) {};
    
    \draw [-latex] (input) node[left]{$x[k]$}  -- (sum);
    \draw [-latex] (sum)  -- (output) node[right]{$x_Q[k]$};
    \draw [-latex] (error) node[below]{$e[k]$} -- (sum);
    
    \draw [dashed] (.5,-1.6) rectangle (3.5,0.5);

\end{tikzpicture}


% =============================================================================
% linear uniform mid-tread quantizer characteristic
\pgfplotsset{axis style={
mathaxis,
ytick={1,2,3,4},
yticklabels={\tiny $Q$},
xtick={-4,0.5,4},
xticklabels={\tiny $x_\text{min}$, \tiny $\frac{Q}{2}$,\tiny $x_\text{max}$},
xlabel=$x$,
}}

\begin{tikzpicture}

\begin{axis}[ylabel={$x_Q$}]
\addplot[blue,thick] plot coordinates{(-6,-4) (-3.5,-4) (-3.5,-3) (-2.5,-3) (-2.5,-2) (-1.5,-2) (-1.5,-1) (-.5,-1) (-.5,0) (.5,0) (.5,1) (1.5,1) (1.5,2) (2.5,2) (2.5,3) (3.5,3) (3.5,4) (6,4) };
\addplot[red,dashed,domain=-5:5,samples=50] { x };
\end{axis};

\end{tikzpicture}


% =============================================================================
% linear uniform mid-rise quantizer characteristic
\pgfplotsset{axis style={
mathaxis,
ytick={.5,1.5,2.5,3.5},
yticklabels={\tiny $\frac{Q}{2}$},
xtick={-4,1,4},
xticklabels={\tiny $x_\text{min}$, \tiny $Q$,\tiny $x_\text{max}$},
xlabel=$x$,
}}

\begin{tikzpicture}

\begin{axis}[ylabel={$x_Q$}]
\addplot[blue,thick] plot coordinates{(-6,-3.5) (-4,-3.5) (-3,-3.5) (-3,-2.5) (-2,-2.5) (-2,-1.5) (-1,-1.5) (-1,-.5) (0,-0.5) (0,0.5) (1,0.5) (1,1.5) (2,1.5) (2,2.5) (3,2.5) (3,3.5) (4,3.5) (6,3.5) };
\addplot[red,dashed,domain=-5:5,samples=50] { x };
\end{axis};

\end{tikzpicture}


% =============================================================================
% block diagram of noise-shaping
\begin{tikzpicture}[auto, node distance=2cm]
    \node [input, name=input] {};
    \node [sum,right of=input, xshift=0cm] (sum){$+$};
	\node [block, right of=sum, xshift=2cm](quantizer){\Large $\mathcal{Q}$};    
    \node [output, right of=quantizer,xshift=1cm] (output) {};
    \node [sum, below of=quantizer,yshift=-.7cm] (sum2) {$+$};
    \coordinate [left=1cm of quantizer] (abzweigL);
    \coordinate [right=1cm of quantizer] (abzweigR);
    \node [block, below of=sum2, xshift=-2cm, yshift=0cm](filter){\Large $h[k]$};    
    
    \draw [-latex] (input) node[left]{$x[k]$}  -- (sum);
    \draw [-latex] (sum) -- (quantizer);
    \draw [-latex] (quantizer) -- (output) node[right]{$x_Q[k]$};
    \draw[-latex] (abzweigL) |- (sum2);
    \draw[-latex] (abzweigR) |- (sum2);
    \draw[-latex] (sum2) |- (filter);
    \draw[-latex] (filter.west) -| (sum.south);
    \node at ($(sum2.center)+(-.7,.2)$) {$-$};
    \node at ($(sum2.center)+(.3,-.7)$) {$e[k]$};
    \node at ($(sum.center)+(-.2,-.7)$) {$-$};

\end{tikzpicture}


% =============================================================================
% block diagram of ideal sampling and quantization w/o anti-aliasing filter
\begin{tikzpicture}[auto, node distance=2cm]
	\node [input, name=input] {};
	\node [sum, right of=input, xshift=1cm](sampling){$\times$};
	\node [block, right of=sampling, xshift=1cm](quantizer){\Large $\mathcal{Q}$};    
    \node [output, right of=quantizer,xshift=0cm] (output) {};
    \node [input, below of=sampling,yshift=1cm] (dirac) {};

	\draw [-latex] (input) node[left]{$x(t)$}  -- (sampling);
	\draw [-latex] (sampling) -- (quantizer);
	\draw [-latex] (quantizer) -- (output) node[right]{$x_Q[k]$};
	\draw [-latex] (dirac) node[below]{$\frac{1}{T} \sha\left(\frac{t}{T}\right)$} -- (sampling);
	\node at ($(sampling.center)+(.7,.25)$) {$x[k]$};

\end{tikzpicture}


% =============================================================================
% block diagram of oversampling w/o anti-aliasing filter
\begin{tikzpicture}[auto, node distance=2cm]
	\node [input, name=input] {};
	\node [sum, right of=input, xshift=1cm](sampling){$\times$};
	\node [block, right of=sampling, xshift=1cm](quantizer){\Large $\mathcal{Q}$};    
    \node [block, right of=quantizer, xshift=1cm](dlowpass){\Large $H_\text{LP}(e^{j \Omega})$};
    \node [block, right of=dlowpass, xshift=1cm](subsampling){\Large $\downarrow L$};
    
    \node [output, right of=subsampling,xshift=0cm] (output) {};    
    \node [input, below of=sampling,yshift=1cm] (dirac) {};

	\draw [-latex] (input) node[left]{$x(t)$} -- (sampling);
	\draw [-latex] (sampling) -- (quantizer);
    \draw [-latex] (quantizer) -- (dlowpass);
    \draw [-latex] (dlowpass) -- (subsampling);
    \draw [-latex] (subsampling) -- (output) node[right]{$x_Q[k]$};
	\draw [-latex] (dirac) node[below]{$\frac{1}{T} \sha\left(\frac{t}{T}\right)$} -- (sampling);
	\node at ($(sampling.center)+(.7,.25)$) {$x[k]$};

\end{tikzpicture}


% =============================================================================
% block diagram of oversampling
\begin{tikzpicture}[auto, node distance=2cm]
	\node [input, name=input] {};
	\node [block, right of=input, xshift=0cm](lowpass){\Large $H_\text{LP}(\omega)$};
	\node [sum, right of=lowpass, xshift=2cm](sampling){$\times$};
	\node [block, right of=sampling, xshift=1cm](quantizer){\Large $\mathcal{Q}$};    
    \node [block, right of=quantizer, xshift=1cm](dlowpass){\Large $H_\text{LP}(e^{j \Omega})$};
    \node [block, right of=dlowpass, xshift=1cm](subsampling){\Large $\downarrow L$};
    
    \node [output, right of=subsampling,xshift=0cm] (output) {};    
    \node [input, below of=sampling,yshift=1cm] (dirac) {};

	\draw [-latex] (input) node[left]{$x(t)$}  -- (lowpass);
	\draw [-latex] (lowpass) -- (sampling);
	\draw [-latex] (sampling) -- (quantizer);
    \draw [-latex] (quantizer) -- (dlowpass);
    \draw [-latex] (dlowpass) -- (subsampling);
    \draw [-latex] (subsampling) -- (output) node[right]{$x_Q[k]$};
	\draw [-latex] (dirac) node[below]{$\frac{1}{T} \sha\left(\frac{t}{T}\right)$} -- (sampling);
	\node at ($(sampling.center)+(.7,.25)$) {$x[k]$};

\end{tikzpicture}






\end{document}